import request from '@/utils/request'

export function fetchBannerList(params) {
  return request({
    url: '/api/banners/page',
    method: 'get',
    params
  })
}

export function getBannerById(id) {
  return request({
    url: `/api/banners/${id}`,
    method: 'get'
  })
}

export function createBanner(data) {
  return request({
    url: '/api/banners',
    method: 'post',
    data
  })
}

export function updateBanner(id, data) {
  return request({
    url: `/api/banners/${id}`,
    method: 'put',
    data
  })
}

export function deleteBanner(id) {
  return request({
    url: `/api/banners/${id}`,
    method: 'delete'
  })
}

// 上传图片
export function uploadBannerImage(data) {
  return request({
    url: '/api/banners/upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}